<?php

class NewsController extends Controller
{
	public $layout='column1';
	public function actionIndex()
	{
		$model = News::model()->findAll();
		$this->pageTitle     = 'Tin tức';
		$criteria            = new CDbCriteria();
		$criteria->condition = 't.del_flg!="1" AND t.show !="1"';
		$criteria->order     = 'id DESC';
		$count = News::model()->count($criteria);
		$pages = new CPagination($count);
		//results per page
		$pages->pageSize = 16;
		$pages->applyLimit($criteria);
		$items = News::model()->findAll($criteria);
		$this->render('index', array(
				'model'		=>	$model,
				'pages'    	=> 	$pages,
				'items'		=>	$items
		));
	}

	// Uncomment the following methods and override them if needed
	/*
	public function filters()
	{
		// return the filter configuration for this controller, e.g.:
		return array(
			'inlineFilterName',
			array(
				'class'=>'path.to.FilterClass',
				'propertyName'=>'propertyValue',
			),
		);
	}

	public function actions()
	{
		// return external action classes, e.g.:
		return array(
			'action1'=>'path.to.ActionClass',
			'action2'=>array(
				'class'=>'path.to.AnotherActionClass',
				'propertyName'=>'propertyValue',
			),
		);
	}
	*/
}